import request from '@/utils/request'

export function getTypeList(playload) {
  return request({
    url: '/get',
    method: 'get',
    params: {
      module: 'CarTypeService.viewCarTypes',
      ...playload
    }
  })
}

export function getCarInfoList(playload) {
  return request({
    url: '/get',
    method: 'get',
    params: {
      module: 'CarService.carInfoList',
      ...playload
    }
  })
}

export function editCarInfoList(playload) {
  let module_name = 'CarService.addCarInfo'
  if (playload.id && playload.id !== '') {
    module_name = 'CarService.updateCarInfo'
  }

  const data = {
    module: module_name,
    ...playload
  }

  return request({
    url: '/post',
    method: 'post',
    data
  })
}

export function editTypeList(playload) {
  let module_name = 'CarTypeService.addCarType'
  if (playload.id && playload.id !== '') {
    module_name = 'CarTypeService.updateCarType'
  }

  const data = {
    module: module_name,
    ...playload
  }

  return request({
    url: '/post',
    method: 'post',
    data
  })
}

export function getTypeName(playload) {
  return request({
    url: '/get',
    method: 'get',
    params: {
      module: 'CarTypeService.getTypeName',
      ...playload
    }
  })
}
